<?php
namespace app\admin\controller;

use app\common\component\help_appointment\HelpAppointmentService;
use app\common\component\help_appointment\HelpAppointmentOldModel;

class Appointment extends ControllerBase {
	public function _initialize() {
		$this -> checkLogin();
	}

    public function index() {
    	$this -> view -> assign('help_appointments', (new HelpAppointmentService()) -> getAll());

        return $this -> view -> fetch();
    }

    public function indexOld() {
    	$resultHelpAppointments = (new HelpAppointmentOldModel()) -> alias('h_a')
    	-> join('league_user u', 'h_a.user_id = u.user_id')
    	-> field(
    		'h_a.help_appointment_id, h_a.appointment_money, h_a.remaining_money, h_a.create_time, h_a.begin_time, h_a.to_num, h_a.status, ' .
    		'u.username'
    	)
    	-> order('h_a.status DESC, h_a.help_appointment_id DESC') -> paginate(10);

    	$this -> view -> assign('help_appointments', $resultHelpAppointments);

        return $this -> view -> fetch();
    }
}
